home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / IEditor / Examples / MultiSelect / MultiSelectMain.c < prev   
Encoding:
C/C++ Source or Header  |  1997-06-17  |  2.3 KB  |  117 lines

  1. /*
  2.     C source code created by Interface Editor
  3.     Copyright © 1994-1996 by Simone Tellini
  4.  
  5.     Generator:  C.generator 37.15 (6.12.96)
  6.  
  7.     Copy registered to :  Simone Tellini
  8.     Serial Number      : #0
  9. */
  10.  
  11. #define INTUI_V36_NAMES_ONLY
  12.  
  13. #include <dos/dos.h>
  14. #include <exec/libraries.h>
  15. #include <clib/exec_protos.h>
  16. #include <clib/dos_protos.h>
  17.  
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20. #include <string.h>
  21. #include <errno.h>
  22.  
  23. #include "MultiSelect.h"
  24. int    main( void );
  25. void   OpenLibs( void );
  26. void   Setup( void );
  27. void   CloseLibs( void );
  28. void   CloseAll( void );
  29. void   PlayTheGame( void );
  30. void   Error( STRPTR, STRPTR );
  31. void   End( ULONG );
  32. int    wbmain( struct WBStartup * );
  33.  
  34. BOOL            Ok_to_Run = TRUE;
  35. ULONG            mask = NULL;
  36.  
  37. extern struct Library    *SysBase;
  38. extern struct Library    *DOSBase;
  39. struct WBStartup        *WBMsg = NULL;
  40. struct Library        *GadToolsBase = NULL;
  41. struct Library        *GfxBase = NULL;
  42. struct Library        *IntuitionBase = NULL;
  43.  
  44. #include "IE_Errors.h"
  45.  
  46. int main( void )
  47. {
  48.     OpenLibs();
  49.     Setup();
  50.     PlayTheGame();
  51.     End( RETURN_OK );
  52. }
  53.  
  54. void End( ULONG RetCode )
  55. {
  56.     CloseAll();
  57.     CloseLibs();
  58.     exit( RetCode );
  59. }
  60.  
  61. void OpenLibs( void )
  62. {
  63.     if (!( GadToolsBase = OpenLibrary( "gadtools.library", 0 )))
  64.         Error( ErrStrings[ OPEN_LIB ], "gadtools.library" );
  65.     if (!( GfxBase = OpenLibrary( "graphics.library", 0 )))
  66.         Error( ErrStrings[ OPEN_LIB ], "graphics.library" );
  67.     if (!( IntuitionBase = OpenLibrary( "intuition.library", 0 )))
  68.         Error( ErrStrings[ OPEN_LIB ], "intuition.library" );
  69. }
  70.  
  71. void Setup( void )
  72. {
  73.     ULONG        ret;
  74.     if ( ret = SetupScreen())
  75.         Error( ErrStrings[ SETUP_SCR ], ErrStrings[ SETUP_SCR+ret ]);
  76.     if ( ret = OpenMainWindow())
  77.         Error( ErrStrings[ OPEN_WND ], ErrStrings[ OPEN_WND+ret ]);
  78. }
  79.  
  80. void CloseAll( void )
  81. {
  82.     CloseMainWindow();
  83.     CloseDownScreen();
  84. }
  85.  
  86. void CloseLibs( void )
  87. {
  88.     if ( GadToolsBase )
  89.         CloseLibrary( GadToolsBase );
  90.     if ( GfxBase )
  91.         CloseLibrary( GfxBase );
  92.     if ( IntuitionBase )
  93.         CloseLibrary( IntuitionBase );
  94. }
  95.  
  96. void PlayTheGame( void )
  97. {
  98.     ULONG    signals;
  99.     ULONG    Main_signal = 1 << MainWnd->UserPort->mp_SigBit;
  100.     mask = mask | SIGBREAKF_CTRL_C | Main_signal;
  101.  
  102.     while( Ok_to_Run ) {
  103.         signals = Wait( mask );
  104.         if (signals & Main_signal)
  105.             Ok_to_Run = HandleMainIDCMP();
  106.         if (signals & SIGBREAKF_CTRL_C)
  107.             Ok_to_Run = FALSE;
  108.     };
  109.  
  110. }
  111.  
  112. int wbmain( struct WBStartup *msg )
  113. {
  114.     WBMsg = msg;
  115.     return( main() );
  116. }
  117.